/*
 * @Author: Simon 1958058172@qq.com
 * @Date: 2025-08-11 15:38:14
 * @LastEditors: Simon 1958058172@qq.com
 * @LastEditTime: 2025-08-11 15:47:44
 * @FilePath: \java.1212\day06\work01\Test.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package day06.work01;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        Collection<Integer> collection=new ArrayList<>();
        collection.add(1);
        collection.add(2);
        collection.add(3);
        collection.add(4);
        collection.add(5);
        //循环1：for+toArray
        Object[] obj=collection.toArray();
        for(int i=0;i<obj.length;i++){
            System.out.println(obj[i]);
        }

        //循环2---迭代器--------------------
        Iterator<Integer> iterator= collection.iterator();
        while (iterator.hasNext()) {
            int number= iterator.next();
            System.out.println(number);
        }

        //循环3---加强for循环------------------
        for(Object object:collection.toArray()){
                System.out.println(object);
        }
    }
}
